import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:surfaceim/common/values/values.dart';
import 'package:get/get.dart';

/// AppBar
AppBar appBar(
    {bool isBack = true,
    String? title,
    Widget? leading,
    List<Widget>? actions,
    double? leadWidth,
    Color? color}) {
  leadWidth != null ? leadWidth = leadWidth : leadWidth = 130.w;
  return AppBar(
    automaticallyImplyLeading: true, // 自动推断 左标 类型
    backgroundColor: Colors.transparent,
    // elevation: 2,
    title: title != null
        ? Text(
            title,
            style: TextStyle(
              color: AppColors.primaryText,
              fontFamily: 'Montserrat',
              fontSize: 36.sp,
              fontWeight: FontWeight.w600,
            ),
          )
        : null,
    titleSpacing: 0.0,
    leadingWidth: leadWidth,
    leading: isBack
        ? IconButton(
            alignment: Alignment.centerLeft,
            icon: Icon(
              Icons.arrow_back_rounded,
              size: 54.sp,
              color: AppColors.tabBarElement,
            ),
            onPressed: () => {Get.back()})
        : Container(
            alignment: Alignment.centerLeft,
            // width: 100,
            // color: Colors.red,
            // margin: EdgeInsets.only(left: 20),
            child: leading,
          ),

    // backgroundColor: color == null ? null : color,
  );
}
